package com.neil.dynamic.manage;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.JdkSerializationRedisSerializer;
import org.springframework.data.redis.serializer.StringRedisSerializer;

/**
 *  动态路由管理启动类
 * @ProjectName:
 * @Package:        com.neil.dynamic.manage
 * @ClassName:      GateWayAdminRouteApplication
 * @Description:    动态路由管理启动类
 * @Author:         Neil.Zhou
 * @CreateDate:     2019/10/14 17:34
 * @UpdateUser:     Neil.Zhou
 * @UpdateDate:     2019/10/14 17:34
 * @UpdateRemark:   The modified content
 * @Version:        1.0
 * <p>Copyright: Copyright (c) 2019/10/14</p>
 *
 */
@EnableDiscoveryClient
@MapperScan({"com.neil.dynamic.manage.respository"})
@SpringBootApplication
public class GateWayAdminRouteApplication {

	public static void main(String[] args) {
		SpringApplication.run(GateWayAdminRouteApplication.class, args);
	}

	/**
	 * Redis模板
	 * @method  redisTemplate
	 * @author  Neil.Zhou
	 * @version
	 * @return
	 * @exception
	 * @date    2019/10/14 17:37
	 */
	@Bean
	public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
		RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();
		redisTemplate.setKeySerializer(new StringRedisSerializer());
		redisTemplate.setHashKeySerializer(new StringRedisSerializer());
		redisTemplate.setValueSerializer(new JdkSerializationRedisSerializer());
		redisTemplate.setHashValueSerializer(new JdkSerializationRedisSerializer());
		redisTemplate.setConnectionFactory(factory);
		return redisTemplate;
	}
}

